




import OpenEXR

import numpy as np 


def demo1():
    height, width = (1080, 1920)
    RGB = np.random.rand(height, width, 3).astype('float32')
    channels = { "RGB" : RGB }
    header = { "compression" : OpenEXR.ZIP_COMPRESSION,
            "type" : OpenEXR.scanlineimage }

    with OpenEXR.File(header, channels) as outfile:
        outfile.write("image.exr")




with OpenEXR.File("image.exr") as infile:

    header = infile.header()
    print(f"type={header['type']}")
    print(f"compression={header['compression']}")

    RGB = infile.channels()["RGB"].pixels
    height, width = RGB.shape[0:2]
    for y in range(height):
        for x in range(width):
            pixel = (RGB[y, x, 0], RGB[y, x, 1], RGB[y, x, 2])
            print(f"pixel[{y}][{x}]={pixel}")


# conda activate llava 

"""

docker run --gpus all --rm -u shaocong.xu -v /baai-cwm-1/baai_cwm_ml:/baai-cwm-1/baai_cwm_ml -w /baai-cwm-1/baai_cwm_ml/algorithm/shaocong.xu/exp/MoGe  baai-cwm-cr01-cn-beijing.cr.volces.com/baai-cwm-cr-namespace/moge:v2 python daniel_scripts/open_exr.py 
"""